﻿@using NCprod.Models;
@using Telerik.Web.Mvc.UI;
@{
    ViewBag.Title = "交易管理--已下订单";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script type="text/javascript">
    $(function () {
    });

    
    function onRowSelected_peisong(orderid) {
        if (confirm('确认配送?')) {
            $.post("/Content/Ttadetoing/", "id=" + orderid, function (result) {
                if (result.Total > 0) {
                    $('#message').css("display", "block");
                    var griddata = $('#ALLPRODUCTS').data('tGrid');
                    griddata.dataBind(result.Data);
                    setInterval(displaymessage, 3000);
                }
                else {
                    $('msg').html('配送失败！');
                    $('#message').css("display", "block");
                }

            });
        }
    }
    function displaymessage() {
        $('#message').css("display", "none");
    }

</script>

@(Html.Telerik().Grid<Commdity5>().Name("ALLPRODUCTS")
                    .Columns(columns =>
                    {
                        columns.Bound(o => o.orderid).Title("订单ID").Hidden();
                        columns.Bound(o => o.com_ID).Title("商品ID").Hidden();
                        
                        columns.Bound(o => o.com_content).Title("图片").Hidden();
                        columns.Bound(o => o.com_ID).Title("图片")
                         .ClientTemplate("<a href=\"#\"  title='图片'\">" +
                        "<img style=\"width:80px;height:80px\" src='<#= com_content #>'></a>")
                                    .Width(80);
                        columns.Bound(o => o.com_name).Title("商品名称").Width(100);
                        columns.Bound(o => o.commodity_num).Title("商品数量").Width(100);
                        columns.Bound(o => o.option5).Title("商品重量").Width(100);
                        columns.Bound(o => o.com_price).Title("交易金额").Width(100);
                        columns.Bound(o => o.com_postage).Title("邮费").Width(100);
                        columns.Bound(o => o.con_id).Title("消费者电话").Width(100);
                        columns.Bound(o => o.con_name).Title("消费者名字").Width(100);
                        columns.Bound(o => o.adress).Title("收货地址").Width(100);
                        columns.Bound(o => o.happendate).Title("下单时间").Width(100);
                        columns.Bound(o => o.orderid).Title("操作")
                            .ClientTemplate("<a href=\"#\"  title='编辑' onclick=\"onRowSelected_peisong(<#= orderid #>)\">" +
                            "<img src='/PIC/back/peisong.png'></a>")
                            .Width(80);
                    })
                                .DataBinding(dataBinding => dataBinding.Ajax().Select("YProductList", "Content"))
                            .Selectable()
                            .Pageable()
                            .Footer(true)
)
<div style="height: 80px;">
    <div id="message" class="alert alert-info" style="display: none; margin-right: 50px;
        margin-top: 20px; float: right; width: 30%">
        <a class="close" data-dismiss="alert" href="#">&times;</a>
        <h4 id="msg">
            配送成功！
        </h4>
    </div>
</div>